﻿using Fee.Orders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Fee.Mapping
{
    public class ConstructionTaskMapping : IEntityTypeConfiguration<ConstructionTask>
    {
        public void Configure(EntityTypeBuilder<ConstructionTask> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();
            builder.HasOne(_ => _.Station);
            builder.HasMany(_ => _.Details).WithOne().HasForeignKey(f => f.TaskId);

            builder.HasMany(_ => _.PlanCosts).WithOne().HasForeignKey(f => f.TaskId);

            builder.HasMany(_ => _.CostDetails);
            builder.ToTable("fee_ConstTask");
        }
    }
}